$(function () {
    vm.init()
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
        gtshow: false,
        dhdshow: false,
        dhdsshow: false,
        byqshow: false,
        kggshow: false,
        qddshow: false,
        dljshow: false,
        voltage_type:[],
        gt_material:[],
        gt_type:[],
        gt_sj:[],
        gt_height:[],
        tjd_kgfa:[],
        tjd_kgzj:[],
        byq_ylx:[],
        byq_cxs:[],
        byq_gz:[],
        gt_count:[],
        byq_rl:[],
        byq_type:[],
        qd_fs:[],
        qd_type:[],
        dPoint: {}
	},
	methods: {

        init: function () {
            $.get(baseURL + "api/bdatadictionary/select?d_code=gt_sj" , function (r) {
                vm.gt_sj = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=gt_height" , function (r) {
                vm.gt_height = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=gt_type" , function (r) {
                vm.gt_type = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=voltage_type" , function (r) {
               vm.voltage_type = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=gt_material" , function (r) {
                vm.gt_material = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=tjd_kgfa" , function (r) {
                vm.tjd_kgfa = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=tjd_kgzj" , function (r) {
                vm.tjd_kgzj = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=byq_ylx" , function (r) {
                vm.byq_ylx = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=byq_cxs" , function (r) {
                vm.byq_cxs = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=byq_gz" , function (r) {
                vm.byq_gz = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=gt_count" , function (r) {
                vm.gt_count = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=byq_rl" , function (r) {
                vm.byq_rl = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=byq_type" , function (r) {
                vm.byq_type = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=qd_fs" , function (r) {
                vm.qd_fs = r.returnlist;
            });
            $.get(baseURL + "api/bdatadictionary/select?d_code=qd_type" , function (r) {
                vm.qd_type = r.returnlist;
            });

            vm.getInfo(GetUrlParam("dpGuid"));
        },
		showall:function (types)
		{   vm.gtshow=false;
            vm.dhdshow=false;
            vm.dhdsshow=false;
            vm.byqshow=false;
            vm.kggshow=false;
            vm.qddshow=false;
            vm.dljshow=false;
            if(types=="杆塔")
			{
				vm.gtshow=true;
			}
            if(types=="搭火点")
            {
                vm.dhdshow=true;
            }
            if(types=="搭火点2")
            {
                vm.dhdsshow=true;
            }

            if(types=="柱上变压器")
            {
                vm.byqshow=true;
            }
            if(types=="开关柜")
            {
                vm.kggshow=true;
            }
            if(types=="墙担点")
            {
                vm.qddshow=true;
            }
            if(types=="电缆井")
            {
                vm.dljshow=true;
            }

		},
	    saveOrUpdate: function (event) {
			var url = vm.dPoint.guid == null ? "bss/dpoint/save" : "bss/dpoint/update";
			$.ajax({
				type: "POST",
			    url: baseURL + url,
                contentType: "application/json",
			    data: JSON.stringify(vm.dPoint),
			    success: function(r){
			    	if(r.code === 0){
						alert('操作成功', function(index){
							vm.reload();
						});
					}else{
						alert(r.msg);
					}
				}
			});
		},

		getInfo: function(guid){

			$.get(baseURL + "bss/dpoint/info/"+guid, function(r){
                vm.dPoint = r.dPoint;
                vm.showall(vm.dPoint.pPName)

            });
		}

	}
});